@model UploadViewModel?
@{
    ViewData["Title"] = "Upload Files";
    int? fileCount = Model?.Files?.Count;
}

@if (!string.IsNullOrEmpty(Model?.Error))
{
    <div class="alert alert-danger" role="alert">
        <h2 class="alert-heading">There was an error uploading the files</h2>
        <p>@Model.Error</p>
    </div>
}
@if (Model?.Files?.Count > 0)
{
    <div class="alert alert-info" role="alert">
        <h2 class="alert-heading">Files were uploaded successfully</h2>
        <table class="table mb-0">
            <thead>
                <tr>
                    <th scope="col">Original File Name</th>
                    <th scope="col">Saved File Name</th>
                </tr>
            </thead>
            <tbody>
            @foreach ((string originalFilename, string savedFilename) in Model.Files)
            {
                <tr>
                    <td>@originalFilename</td>
                    <td>@savedFilename</td>
                </tr>
            }
            </tbody>
        </table>
    </div>
}

<h2>@ViewData["Title"]</h2>
<form enctype="multipart/form-data" method="post" asp-controller="Files" asp-action="Upload">
    <dl>
        <dt>
            <label for="files">Upload one or more files with this form:</label>
        </dt>
        <dd>
            <input type="file" name="files" id="files" multiple class="form-control"/>
        </dd>
    </dl>
    <input class="btn btn-primary" type="submit" value="Upload file(s)"/>
</form>
